# include<stdio.h>
# include<stdlib.h>

typedef struct two_para
{
       char *  para1;//参数1
       char *  para2;//参数2   
}two_para;
int mycp( char * paras)
{
	char* copyPath, * pastePath;

    two_para *cp_paras = (two_para *)paras;
    copyPath = cp_paras->para1;
    pastePath = cp_paras->para2;
	
	//声明变量
	FILE* fp_r,*fp_w;
	char buf[1];
	//使用标准库函数尝试打开文件
	//以‘rt’文本形式打开file1
	if((fp_r = fopen(copyPath,"rt"))==NULL)
	{
		printf("Fail to open file:%s\n",copyPath);
		return(1);//异常退出
	} 
	//以‘w’文本形式打开file2（若文件存在则clear文件内容。若文件不存在则建立该文件）
	else if((fp_w = fopen(pastePath,"w"))==NULL){
		printf("Fail to open file:%s\n",copyPath);
		return(1);//异常退出
	}
	else{
		while(!feof(fp_r))//当指针指向文件末尾时返回0
		{
			int i=0;
			//先读,每次读量为char[1]
			if((fread(buf,sizeof(char),1,fp_r))!=0)
			{
				//再写
				if(fwrite(buf,sizeof(buf),1,fp_w))
				{;}
				
			}	
		}
	}

	printf("Copy & Paste completed ! \n\n");

	//退出程序之前关闭文件指针
	fclose(fp_r);
	fclose(fp_w);
	return 0;
}
